package job01b;
//定义一个Computer类，包含品牌和CPU频率属性
class Computer{
	String brand; // 品牌名称
	int cpuHz;  // CPU频率（单位：GHz）
}
//定义一个Job01_1类，包含学生信息和使用的电脑
public class Job01_1 {
	String sname;//学生姓名
	Computer c;//所用电脑
	// study方法，输出学生正在使用的电脑品牌和CPU频率
	void study() {
		System.out.println("我正在学习！使用我们的电脑，姓名："+sname+"   "+c.brand+"  .cpu:"+c.cpuHz);
	}
	//main，用于创建学生对象和电脑对象，并调用study方法
	public static void main(String[] args) {
		//创建四个电脑四个学生
		Computer comp1 = new Computer();
		comp1.brand = "联想";
		comp1.cpuHz = 4;
		
		Computer comp2 = new Computer();
		comp2.brand = "MAC";
		comp2.cpuHz = 6;	
		
		Computer comp3 = new Computer();
		comp3.brand = "华为";
		comp3.cpuHz = 8;
		
		Computer comp4 = new Computer();
		comp4.brand = "SURFACE";
		comp4.cpuHz = 4;	
		
		
		Job01_1 s1 = new Job01_1();
		s1.sname = "小红";		
		
		Job01_1 s2 = new Job01_1();
		s2.sname = "小明";	
		
		Job01_1 s3 = new Job01_1();
		s3.sname = "小丽";
		
		Job01_1 s4 = new Job01_1();
		s4.sname = "小华";
		
	     // 为每个学生分配电脑并调用study方法
		s1.c = comp1;
		s1.study();
		
		s2.c = comp3;
		s2.study();
		
		s3.c = comp2;
		s3.study();
		
		s4.c = comp1;
		s4.study();
		
		}

}
	